IBM regular Expressions

The iSphere search feature relies on the IBM regular expression functions and uses regcomp() for compiling regular expressions. This function follows more of a Posix/Unix specification, as stated by IBM support. Therefore some commonly used character classes to not work, for example \s for white spaces.

For example, comonly used expression when searching for white spaces are:

  dcl-f +filea
  dcl-f\s+filea
  dcl-f[ ]+filea
  dcl-f[\s]+filea
  
Let as assume we had the following input data:
  dcl-f filea;
  dcl-f  filea;
  dcl-f   filea;
  dcl-f   fileb;
  
In that case we would get three matches, namely for the first three lines. The fourth line does not match the expression, because of the 'fileb' literal.

Not so the regcomp() function. It does not understand the \s character class for white spaces and hence searches for a back-slash (\) followed by letter 'a'.

Instead of using \s, you have to pass [:space:] to regcomp() to search for white spaces. But that only works when used in a character set. So you have to enclose [:space:] into [], which makes it look like this:

  dcl-f[[:space:]]+filea
  
It is not very surprising, that other languages does not support Posix expressions, such as [:space:].

Please refer to the following documents to learn more about Posix regular expressions. The first link was provided by IBM support. Thank you IBM support.

Due to the lack of a complete description of regcomp(), it is up to you to figure out what Posix expressions work with regcomp() and which expressions are not supported.